package com.xiami.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.xiami.mapper.EmpMapper;
import com.xiami.pojo.Emp;
import com.xiami.pojo.PageBean;
import com.xiami.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/*
创建者:虾米糖
*/
@Service
public class EmpServiceImpl implements EmpService {
    @Autowired
    private EmpMapper empMapper;
    @Override
    public PageBean list(Integer page, Integer pageSize) {
        //1.设置分页参数
        PageHelper.startPage(page,pageSize);
        //2.执行查询
       List<Emp> list = empMapper.list();
        Page<Emp> p = (Page<Emp>) list;

      PageBean pageBean = new PageBean(p.getTotal(), p.getResult());
        return pageBean;

    }

    @Override
    public Emp login(Emp emp) {
       Emp e = empMapper.getByUserNameAndPassword(emp);
       return e;
    }
}
